home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / computer vision recognition / rcinstall.exe / Disk1 / data1.cab / ASP_Pages / UtilBody.asp < prev    next >
Encoding:
Text File  |  2001-12-12  |  16.7 KB  |  474 lines

  1. <!------------------------------------------------------------------------------------------------- 
  2.                           Copyright by Kofax Image Products                    
  3. -------------------------------------------------------------------------------------------------->
  4.  
  5. <%@ LANGUAGE = VBScript %>
  6. <%
  7.     Response.Expires = 60
  8.     Response.Expiresabsolute = Now() - 1
  9.     Response.AddHeader "pragma","no-cache"
  10.     Response.AddHeader "cache-control","private"
  11.     Response.CacheControl = "no-cache"
  12.     if Application("PubTypesPath")="" then
  13.         Dim Vroot,iCount,idx
  14.         Vroot = Server.MapPath("Default.asp")
  15.         iCount = 0
  16.         idx = InStrRev(Vroot, "\")
  17.         if (idx > 0) and (idx < len(Vroot)) then
  18.                 Vroot = Left(Vroot,idx-1)
  19.         end if
  20.         Application("PubTypesPath")=Vroot & "\PubTypes"
  21.         Application("XMLDirectory")=Vroot & "\XMLBATCH"
  22.         Application("SiteIDFile")=Vroot & "\siteid.txt"
  23.         Application("LogFile")=Vroot & "\csweblog.txt"
  24.     end if
  25. '---------------------------------------------------------------------------------------------------
  26. 'Getting local strings
  27. '--------------------------------------------------------------------------------------------------
  28.  
  29.         dim oConn,oRs,i,sFilePath,sLangTable
  30.         dim display(8) 
  31.         on error resume next
  32.         set oConn = Server.CreateObject("ADODB.Connection")
  33.         sFilePath=Server.MapPath("csuiweb.mdb")
  34.         
  35.         oConn.Open("Driver={Microsoft Access Driver (*.mdb)};DBQ=" & sFilePath & ";")
  36.         if err then
  37.                set oConn=nothing
  38.             err.clear
  39.             Response.Redirect("Error.asp?Err=1")
  40.         end if
  41.         sLangTable=mid(Request.ServerVariables("HTTP_ACCEPT_LANGUAGE"),1,2)
  42.         if trim("" & sLangTable)="" then
  43.             sLangTable="En"
  44.         end if    
  45.         Set oRs=oConn.Execute("SELECT * FROM " & sLangTable & " WHERE Id=0")
  46.         if (err and (Err.Number=-2147217865)) then        
  47.             err.Clear
  48.             sLangTable="En"
  49.             Set oRs=oConn.Execute("SELECT * FROM " & sLangTable & " WHERE Id=0")
  50.         end if        
  51.         Response.Write("<META HTTP-EQUIV='CONTENT-LANGUAGE' CONTENT='" & oRS("Value") & "'>")
  52. 'Create
  53.         Set oRs=oConn.Execute("SELECT * FROM " & sLangTable & " WHERE Id=6")
  54.         display(0)=oRs("Value")
  55. 'Document name
  56.         Set oRs=oConn.Execute("SELECT * FROM " & sLangTable & " WHERE Id=31")
  57.         display(1)=oRs("Value")
  58. 'Please wait....
  59.         Set oRs=oConn.Execute("SELECT * FROM " & sLangTable & " WHERE Id=8")
  60.         display(2)=oRs("Value")
  61. 'Required index field message 1
  62.         Set oRs=oConn.Execute("SELECT * FROM " & sLangTable & " WHERE Id=32")
  63.         display(3)=oRs("Value")
  64. 'Required index field message 2
  65.         Set oRs=oConn.Execute("SELECT * FROM " & sLangTable & " WHERE Id=33")
  66.         display(4)=oRs("Value")
  67. 'Valid index field message 1
  68.         Set oRs=oConn.Execute("SELECT * FROM " & sLangTable & " WHERE Id=34")
  69.         display(5)=oRs("Value")
  70. 'Valid index field message 2
  71.         Set oRs=oConn.Execute("SELECT * FROM " & sLangTable & " WHERE Id=35")
  72.         display(6)=oRs("Value")
  73. 'The batch catalog may be changed. Please refresh Utility window for getting correct data and continuing...        
  74.         Set oRs=oConn.Execute("SELECT * FROM " & sLangTable & " WHERE Id=36")
  75.         display(7)=oRs("Value")
  76. 'Error on getting published data.ActiveX can not create component.
  77.         Set oRs=oConn.Execute("SELECT * FROM " & sLangTable & " WHERE Id=37")
  78.         display(8)=oRs("Value")
  79.  
  80.         oRs.Close
  81.         oConn.Close    
  82.         if err then
  83.             err.clear
  84.             Response.Redirect("Error.asp?Err=1")
  85.         end if    
  86. %>
  87. <html>
  88. <head>
  89. <script language="JavaScript">
  90.     var iTimer;
  91. /*trim(StrIn) function is used for cutting all unnecessary black spaces*/
  92.     function trim(StrIn)
  93.     {
  94.         var StrOut=StrIn;
  95.         var s="";
  96.         s=StrOut.charAt(0);
  97.         while ((s == " ")&&(StrOut.length>0))
  98.         {
  99.             StrOut=StrOut.substr(1);
  100.             s=StrOut.charAt(0);
  101.         }
  102.         s=StrOut.charAt(StrOut.length-1);
  103.         while ((s == " ")&&(StrOut.length>0))
  104.         {
  105.             StrOut=StrOut.substring(0,StrOut.length-1);
  106.             s=StrOut.charAt(StrOut.length-1);
  107.         }
  108.         return StrOut;        
  109.         
  110.     }
  111. /*end of trim function*/
  112.  
  113. /*--------------------------------------------------------------------------------------------*/
  114.  
  115.  
  116. /*
  117.     CorrectStr(StrIn) function will replace all acute,quot characters of a string by "´", """ string  
  118.     Input: StrIn - a string
  119.     Output:a string that is StrIn after replacing
  120. */
  121.     function CorrectStr(StrIn)
  122.     {
  123.         var OS,i;
  124.         OS=StrIn.replace("\'","´");
  125.         i=OS.search("\'");
  126.         while (i>=0)
  127.         {
  128.         OS=OS.replace("\'","´");
  129.         i=OS.search("\'");
  130.         }
  131.         OS=OS.replace("\"",""");    
  132.         i=OS.search("\"");
  133.         while (i>=0)
  134.         {
  135.         OS=OS.replace("\"",""");    
  136.         i=OS.search("\'");
  137.         }    
  138.         return OS;
  139.     }
  140. /*end of CorrectStr function*/
  141. /*--------------------------------------------------------------------------------------------*/
  142. /*
  143.     ValidStr(StrIn) function will check that a string has got any substring "´" or """
  144.     Input:  StrIn - a string will be checked
  145.     Output: true  - if the string does not contain both "´" or """ substring
  146.             false - if not 
  147. */ 
  148.     function ValidStr(StrIn)
  149.     {    
  150.         var i;
  151.         i=StrIn.indexOf("\´");
  152.         if (i>=0)
  153.         {
  154.             return false;
  155.         } 
  156.         i=StrIn.indexOf("\"");
  157.         if (i>=0)
  158.         {
  159.             return false;
  160.         } 
  161.         return true;
  162.     
  163.     }
  164. /* End of ValidStr function*/
  165.  
  166. /*--------------------------------------------------------------------------------------------*/
  167.  
  168. /*
  169.     Function SubmitForm is used for sending all data of Utility window to Default window and calling its submitform method
  170. */    
  171.     function SubmitForm()
  172.     {
  173.         var Flag=true;
  174.         var nTemp;
  175.     //Checking valid input data
  176.         if (parseInt(document.frmIndexField.IndexFieldNumber.value)>1)
  177.             {        
  178.                 for (nTemp=0;nTemp<document.frmIndexField.IndexFieldName.length;nTemp++)
  179.                     {
  180.                         document.frmIndexField.IndexFieldValue[nTemp].value=trim(document.frmIndexField.IndexFieldValue[nTemp].value);
  181.                         if ((document.frmIndexField.IndexFieldValue[nTemp].value=="")&&(document.frmIndexField.Required[nTemp].value=="True"))
  182.                         {
  183.                             alert(CorrectStr(document.frmIndexField.RequiredIFMsg1.value + " " + document.frmIndexField.IndexFieldName[nTemp].value + " " + document.frmIndexField.RequiredIFMsg2.value));
  184.                             document.frmIndexField.IndexFieldValue[nTemp].focus();
  185.                             Flag=false;
  186.                             break;
  187.                         }
  188.                         else
  189.                         {
  190.                             if (!ValidStr(document.frmIndexField.IndexFieldValue[nTemp].value))
  191.                             {
  192.                                 alert(CorrectStr(document.frmIndexField.ValidIFMsg1.value + " " + document.frmIndexField.IndexFieldName[nTemp].value + " " + document.frmIndexField.ValidIFMsg2.value));
  193.                                 document.frmIndexField.IndexFieldValue[nTemp].focus();
  194.                                 Flag=false;
  195.                                 break;
  196.                             }
  197.                             
  198.                         }
  199.                     }        
  200.             }
  201.         else
  202.             {
  203.                 if     (parseInt(document.frmIndexField.IndexFieldNumber.value)==1)
  204.                     {    
  205.                         document.frmIndexField.IndexFieldValue.value=trim(document.frmIndexField.IndexFieldValue.value);
  206.                         if ((document.frmIndexField.IndexFieldValue.value=="")&&(document.frmIndexField.Required.value=="True"))
  207.                         {
  208.                             alert(CorrectStr(document.frmIndexField.RequiredIFMsg1.value + " " + document.frmIndexField.IndexFieldName.value + " " + document.frmIndexField.RequiredIFMsg2.value));
  209.                             document.frmIndexField.IndexFieldValue.focus();
  210.                             Flag=false;
  211.                         }
  212.                         else
  213.                         {
  214.                             if (!ValidStr(document.frmIndexField.IndexFieldValue.value))
  215.                             {
  216.                                 alert(CorrectStr(document.frmIndexField.ValidIFMsg1.value + " " + document.frmIndexField.IndexFieldName.value + " " + document.frmIndexField.ValidIFMsg2.value));
  217.                                 document.frmIndexField.IndexFieldValue.focus();
  218.                                 Flag=false;
  219.                             }
  220.                         }
  221.                     }    
  222.             }        
  223.     //end of checking valid data
  224.         if (Flag)
  225.     //All data are valid
  226.             {
  227.     //Giving data back to default page        
  228.                 var s;
  229.     //s contains all returned data        
  230.     //generating data that are contained in the s variant
  231.     
  232.                 s="<input type='Hidden' name='BatchClassName' value='" + CorrectStr(document.frmIndexField.BatchClassName.value) + "'>";
  233.                 s=s + "<input type='Hidden' name='BatchClassID' value='" + CorrectStr(document.frmIndexField.BatchClassID.value) + "'>";
  234.                 s=s + "<input type='Hidden' name='Priority' value='" + CorrectStr(document.frmIndexField.Priority.value) + "'>";
  235.                 s=s + "<input type='Hidden' name='DocumentClassName' value='" + CorrectStr(document.frmIndexField.DocumentClassName.value) + "'>";
  236.                 s=s + "<input type='Hidden' name='FormTypeName' value='" + CorrectStr(document.frmIndexField.FormTypeName.value) + "'>";
  237.                 s=s + "<input type='Hidden' name='FixedPageCount' value='" + CorrectStr(document.frmIndexField.FixedPageCount.value) + "'>";
  238. //                s=s + "<input type='Hidden' name='DocumentName' value='" + CorrectStr(document.frmIndexField.DocumentName.value) + "'>";
  239.                 s=s + "<input type='Hidden' name='DocumentName' value=''";
  240.                 s=s + "<input type='Hidden' name='BatchFieldNumber' value='" + CorrectStr(document.frmIndexField.BatchFieldNumber.value) + "'>";
  241.         //Adding batch fields information
  242.                 if (parseInt(document.frmIndexField.BatchFieldNumber.value)==1)
  243.                 {
  244.                             s=s + "<input type='Hidden' name='BatchFieldName' value='" + CorrectStr(document.frmIndexField.BatchFieldName.value) + "'>";            
  245.                 }
  246.                 else
  247.                 {
  248.                     if (parseInt(document.frmIndexField.BatchFieldNumber.value)>1)
  249.                     {
  250.                         for (nTemp=1;nTemp<parseInt(document.frmIndexField.BatchFieldNumber.value);nTemp++)
  251.                         {
  252.                             s=s + "<input type='Hidden' name='BatchFieldName' value='" + CorrectStr(document.frmIndexField.BatchFieldName[nTemp].value) + "'>";
  253.                         }
  254.                     }
  255.                 }
  256.         //Adding index fields information    
  257.                 s=s + "<input type='Hidden' name='IndexFieldNumber' value='" + CorrectStr(document.frmIndexField.IndexFieldNumber.value) + "'>";
  258.                 if (parseInt(document.frmIndexField.IndexFieldNumber.value)>1)
  259.                 {        for (nTemp=0;nTemp<document.frmIndexField.IndexFieldName.length;nTemp++)
  260.                         {
  261.                             s=s + "<input type='Hidden' name='IndexFieldName' value='" + CorrectStr(document.frmIndexField.IndexFieldName[nTemp].value) + "'>";
  262.                             s=s + "<input type='Hidden' name='IndexFieldValue' value='" + CorrectStr(document.frmIndexField.IndexFieldValue[nTemp].value) + "'>";
  263.                         }
  264.                 
  265.                 }
  266.                 else
  267.                 {
  268.                     if (parseInt(document.frmIndexField.IndexFieldNumber.value)==1)
  269.                         {                
  270.                             s=s + "<input type='Hidden' name='IndexFieldName' value='" + CorrectStr(document.frmIndexField.IndexFieldName.value) + "'>";
  271.                             s=s + "<input type='Hidden' name='IndexFieldValue' value='" + CorrectStr(document.frmIndexField.IndexFieldValue.value) + "'>";
  272.                         }    
  273.                 }        
  274.     //End of generating
  275.     //Submit form
  276.                 var oOpener = top.dialogArguments;
  277.                 oOpener.sTitle="<b><i>" + document.frmIndexField.ProcessingText.value + "</i></b>";
  278.                 oOpener.sFlag="<input type='Hidden' name='Submited' value='True'>"
  279.                 oOpener.sReturnData = s;
  280.                 oOpener.Update();
  281.                 top.close();
  282.                 return true;
  283.         }
  284.         else
  285.         {
  286.             return false;
  287.         }
  288.     }
  289.  
  290. /* End of SubmitForm function*/
  291.  
  292. /*------------------------------------------------------------------------------------------------*/
  293.     
  294. /* SetFocus() function performs setting focus to the first text box*/
  295.     function init()
  296.     {
  297.         iTimer=window.setInterval("SetFocus()",50);
  298.     }
  299.     function SetFocus()
  300.     {
  301.         if (document.frmIndexField.elements.length>0)
  302.         {
  303.             if (StoreData.innerHTML!="")
  304.             {
  305.                 try
  306.                 {
  307.                     if (parseInt(document.frmIndexField.IndexFieldNumber.value)>0)
  308.                     {
  309.                         if (parseInt(document.frmIndexField.IndexFieldNumber.value)==1)
  310.                         {
  311.                             document.frmIndexField.IndexFieldValue.focus();        
  312.                         }
  313.                         else            
  314.                         {
  315.                             document.frmIndexField.IndexFieldValue[0].focus();        
  316.                         }
  317.                         window.clearInterval(iTimer);
  318.                     }
  319.                 }    
  320.                 catch (e)
  321.                     {
  322.                     }
  323.             }
  324.             else
  325.             {
  326.                 window.clearInterval(iTimer);                
  327.             }
  328.         }
  329.         else
  330.         {
  331.                         window.clearInterval(iTimer);                        
  332.         }    
  333.     }
  334. </script>
  335.     <title>Untitled</title>
  336.     <link rel="stylesheet" href="coversheet.css">
  337.         
  338. </head>
  339.  
  340. <body bgcolor="#A1AED0" onload="init();" >
  341.  
  342. <form target="_self" onsubmit="return SubmitForm();" action='UtilBody.asp?lang=<%=Request.QueryString("lang")%>' name="frmIndexField" method="post" >
  343. <%
  344. 'Checking changes of header page
  345.     if Request.Form("selecteddata")="" then
  346.         response.write("<div id='StoreData' style='visibility:hidden;'></div>")
  347.     else
  348.         dim oXML,nTemp,sBatch,sDocument,sForm
  349.         Dim nB,nD,nF,bFlag,sTest
  350.         on error resume next
  351.         set oXML=CreateObject("RCXMLWEB.RCXMLUI")
  352.         if err then
  353.            response.write("<table><tr><td class='errorMessage'>" & display(8) & "</td></tr></table>")
  354.            Response.End
  355.         end if
  356.     'Used for getting sample image file
  357.     '        nTemp=oXML.SetInfo(Application("PubTypesPath"),sWebRoot) 
  358.     'getting batch catalog information
  359.         nTemp=oXML.SetInfo(Application("PubTypesPath")) 
  360.         if nTemp<0 then
  361.             dim fso,f
  362.             Set fso = CreateObject("Scripting.FileSystemObject")
  363.             set f =fso.OpenTextFile(Application("LogFile"),8,true)
  364.             f.WriteLine oXML.ErrMessage
  365.             f.Close
  366.             set fso=nothing                       
  367.         end if
  368.         bFlag=False
  369.     'Checking the change
  370.         for nB=1 to oXML.Batches.Count
  371.             for nD=1 to oXML.Batches(nB).Documents.Count
  372.                 for nF=1 to oXML.Batches(nB).Documents(nD).FormTypes.Count
  373.                     sTest="" & oXML.Batches(nB).BatchClassID & "-" & oXML.Batches(nB).Documents(nD).DocumentClassName & "-" & oXML.Batches(nB).Documents(nD).FormTypes(nF).FormTypeName     
  374.                     if (sTest=("" & Request.Form("selecteddata"))) then
  375.                         bFlag=true
  376.                         exit for
  377.                     end if
  378.                 next
  379.                 if bFlag=true then
  380.                        exit for
  381.                 end if
  382.             next
  383.             if bFlag=true then
  384.                    exit for
  385.             end if
  386.         next            
  387.         if bFlag=false then
  388.             set oXML = nothing
  389.             response.write("<table><tr><td class='errorMessage'>" & display(7) & "</td></tr></table>")
  390.             response.write("<script language='JavaScript'>top.resizeBy (0,-50);</script> ")
  391.             response.end
  392.         end if
  393.         %>    
  394.         <input type="Hidden" name="IndexFieldNumber" value='<%=oXML.Batches(nB).Documents(nD).FormTypes(nF).visibleIndexFields.Count%>'>
  395.         <input type="Hidden" name="RequiredIFMsg1" value='<%=display(3)%>'>
  396.         <input type="Hidden" name="RequiredIFMsg2" value='<%=display(4)%>'>
  397.         <input type="Hidden" name="ValidIFMsg1" value='<%=display(5)%>'>
  398.         <input type="Hidden" name="ValidIFMsg2" value='<%=display(6)%>'>
  399.         <input type="Hidden" name="BatchClassName" value='<%=oXML.Batches(nB).BatchClassName%>'>
  400.         <input type="Hidden" name="BatchClassID" value='<%=oXML.Batches(nB).BatchClassID%>'> 
  401.         <input type="Hidden" name="Priority" value='<%=oXML.Batches(nB).Priority%>'>
  402.         <input type="Hidden" name="BatchFieldNumber" value='<%=oXML.Batches(nB).BatchFields.Count%>'>
  403.         <%
  404.         for nTemp=1 to oXML.Batches(nB).BatchFields.Count
  405.         %>
  406.          <input type="Hidden" name="BatchFieldName" value='<%=oXML.Batches(nB).BatchFields(nTemp).Name%>'>     
  407.          <input type="Hidden" name="BatchFieldValue" value='<%=oXML.Batches(nB).BatchFields(nTemp).Value%>'>
  408.         <%
  409.         next
  410.         %>      
  411.         <input type="Hidden" name="DocumentClassName" value='<%=oXML.Batches(nB).Documents(nD).DocumentClassName%>'>    
  412.         <input type="Hidden" name="FormTypeName" value='<%=oXML.Batches(nB).Documents(nD).FormTypes(nF).FormTypeName%>'>
  413.         <input type="Hidden" name="FixedPageCount" value='<%=oXML.Batches(nB).Documents(nD).FormTypes(nF).FixedPageCount%>'>
  414.         <table border="0" cellpadding="0" cellspacing="1">
  415.         
  416.         <%
  417.         for nTemp=1 to oXML.Batches(nB).Documents(nD).FormTypes(nF).visibleIndexFields.Count
  418.             %>
  419.         <tr>
  420.             <td  class="indexlabels"><%=oXML.Batches(nB).Documents(nD).FormTypes(nF).visibleIndexFields(nTemp).Name%>
  421.             <input type="Hidden" name="IndexFieldName" value='<%=oXML.Batches(nB).Documents(nD).FormTypes(nF).visibleIndexFields(nTemp).Name%>'>
  422.             <input type="Hidden" name="Required" value='<%=oXML.Batches(nB).Documents(nD).FormTypes(nF).visibleIndexFields(nTemp).Required%>'>                
  423.             <% if oXML.Batches(nB).Documents(nD).FormTypes(nF).visibleIndexFields(nTemp).Required=True then
  424.             %>
  425.             <font color="Red">*</font>    
  426.             <% end if%>   
  427.             </td>                
  428.         </tr>
  429.         <tr>
  430.             <td>
  431.                 <input type="Text" class="inputBox" name="IndexFieldValue" size="40" maxlength='<%=oXML.Batches(nB).Documents(nD).FormTypes(nF).visibleIndexFields(nTemp).MaxLength%>'  >                 
  432.             </td>
  433.         </tr>
  434.         <tr>
  435.             <td height="3"></td>
  436.         </tr>            
  437.             <%        
  438.         next
  439.         set oXML=nothing        
  440.         %>
  441. <!--- 
  442.         <tr>
  443.         <td height="4" valign="midle"><hr color="Black" size="1"></td>
  444.         </tr>
  445.         <tr>
  446.         <td  class="indexlabels"><%=display(1)%></td>
  447.         </tr>
  448.         <tr>
  449.         <td>
  450.             <input type="Text" class="inputBox" name="DocumentName" size="40" maxlength="32">
  451.         </td>
  452.         </tr>
  453.  
  454.  --->
  455.          <tr >
  456.         <td height="4" valign="midle"><hr color="Black" size="1"></td>
  457.         </tr>
  458.         <tr>
  459.         <td>
  460.             <input type="Submit" name="Submit" value='<%=display(0)%>' >
  461.         </td>
  462.         </tr>
  463.         </table>
  464.         <div id="StoreData" style="visibility:hidden;">
  465.         <input type="Hidden" name="selecteddata" value='<%=request.Form("selecteddata")%>'> 
  466.         </div>
  467.         <%
  468.     end if
  469.     %>
  470.     <input type="Hidden" name="ProcessingText" value='<%=display(2)%>'>
  471. </form>
  472. </body>
  473. </html>
  474.